lib/pull: Don't leave commits pulled by depth as partial
authorJonathan Lebon <jonathan@jlebon.com>
Thu, 19 Mar 2020 14:05:57 +0000 (10:05 -0400)
committerJonathan Lebon <jonathan@jlebon.com>
Thu, 19 Mar 2020 14:10:50 +0000 (10:10 -0400)
When pulling full parent commits via e.g. `--depth N`, we weren't
unmarking them as partial in the out path.

Closes: #2035
src/libostree/ostree-repo-pull.c
tests/test-local-pull-depth.sh

index 125c113d53c530a3068a1b030568877eafbcdc96..381cce479cc7ea06dd5bb7d647b5dcbca6ebda1d 100644 (file)
@@ -4719,6 +4719,13 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
           if (!ostree_repo_mark_commit_partial (pull_data->repo, commit, FALSE, error))
             goto out;
         }
+
+      /* and finally any parent commits we might also have pulled because of depth>0 */
+      GLNX_HASH_TABLE_FOREACH (pull_data->commit_to_depth, const char*, commit)
+        {
+          if (!ostree_repo_mark_commit_partial (pull_data->repo, commit, FALSE, error))
+            goto out;
+        }
     }
 
   ret = TRUE;
index 7080e121425550fe814412706db1697a7c910526..96b20b9cd9290f95f9d53532935e77766248fc65 100755 (executable)
@@ -34,21 +34,31 @@ ostree_repo_init repo2 --mode="archive"
 ${CMD_PREFIX} ostree --repo=repo2 pull-local repo
 find repo2/objects -name '*.commit' | wc -l > commitcount
 assert_file_has_content commitcount "^1$"
+find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
+assert_file_has_content commitpartialcount "^0$"
 
 ${CMD_PREFIX} ostree --repo=repo2 pull-local --depth=0 repo
 find repo2/objects -name '*.commit' | wc -l > commitcount
 assert_file_has_content commitcount "^1$"
+find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
+assert_file_has_content commitpartialcount "^0$"
 
-${CMD_PREFIX} ostree --repo=repo2 pull-local --depth=1 repo
+${CMD_PREFIX} ostree --repo=repo2 pull-local --depth=1 --commit-metadata-only repo
 find repo2/objects -name '*.commit' | wc -l > commitcount
 assert_file_has_content commitcount "^2$"
+find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
+assert_file_has_content commitpartialcount "^1$"
 
 ${CMD_PREFIX} ostree --repo=repo2 pull-local --depth=1 repo
 find repo2/objects -name '*.commit' | wc -l > commitcount
 assert_file_has_content commitcount "^2$"
+find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
+assert_file_has_content commitpartialcount "^0$"
 
 ${CMD_PREFIX} ostree --repo=repo2 pull-local --depth=-1 repo
 find repo2/objects -name '*.commit' | wc -l > commitcount
 assert_file_has_content commitcount "^2$"
+find repo2/state -name '*.commitpartial' | wc -l > commitpartialcount
+assert_file_has_content commitpartialcount "^0$"
 
 echo "ok local pull depth"